package br.edu.unibratec.Projeto.controller;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.text.format.DateFormat;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class EventoAdapter extends BaseAdapter {

	private List<Evento> eventos;
	private Context contexto;
	private List<Parada> paradas;
	private Parada parada;
		
	
	public EventoAdapter(List<Evento> eventos, List<Parada> paradas, Parada parada, Context contexto) {
		super();
		this.eventos = eventos;
		this.paradas = paradas;
		this.parada = parada;
		this.contexto = contexto;
	}

	public int getCount() {
				
		return eventos.size();
	}

	public Object getItem(int position) {
		
		return eventos.get(position);
	}

	public long getItemId(int arg0) {
		
		return 0;
	}

	public View getView(int position, View v, ViewGroup vg) {
		
		Evento evento = (Evento) this.getItem(position);

		TextView txtview = new TextView(this.contexto);
		txtview.setTextSize(25);
		String date = (String) DateFormat.format("dd/MM/yyyy - KK:mm", evento.getData());
		txtview.setText(evento.getDescricao() + " : " + date + " : " + parada.getNome() );
		txtview.setBackgroundColor(Color.GREEN);
		if (evento.isAtivo()) {
			txtview.setBackgroundColor(Color.RED);
		}else{
			txtview.setBackgroundColor(Color.GREEN);
		}
	
		return txtview;
	}

}
